<?php

class Tintuc extends CI_Controller{
    public function __construct() {
        parent::__construct();
        $this->load->helper("url");
	$this->load->library('my_layout');
	$this->my_layout->setLayout("layout/frontend");
        $this->load->model('tintuc_model');
    }
    function index() {
        $data['tintuc'] = $this->tintuc_model->get_all()->result_array();
        
        $this->load->model('loaitrungtam_model');
        $data['loaitrungtam'] = $this->loaitrungtam_model->get_all()->result_array();
        
        $this->my_layout->view('frontend/news',$data);
    }
    function phanloai($id_phanloai) {
        
        $data['tintuc'] = $this->tintuc_model->get_by_loaiTT($id_phanloai)->result_array();
        
        $this->load->model('loaitrungtam_model');
        $data['loaitrungtam'] = $this->loaitrungtam_model->get_all()->result_array();
        
        $data['id_phanloai'] = $id_phanloai;
        
        $this->my_layout->view('frontend/news',$data);
    }
    function loadById($id) {
        $data['tintuc'] = $this->tintuc_model->get_by_id($id)->row_array();
        
        $this->load->model('loaitrungtam_model');
        $data['loaitrungtam'] = $this->loaitrungtam_model->get_all()->result_array();
        
        $data['id_tintuc'] = $id;
        
        $this->my_layout->view('frontend/new',$data);
    }
    
}

